import { Allow, IsAlphanumeric, IsNotEmpty, MaxLength } from 'class-validator'
import { IsEnterPassword } from '../../custom-valid/isEnterPasswrod'
import { IsNotExist } from 'src/custom-valid/isNotExist'

export class RegisterDto {
   @IsNotEmpty({ message: '用户名不能为空' })
   @IsAlphanumeric('en-US', { message: '用户名只能是数字和字母' })
   @MaxLength(10, { message: '长度不能大于10' })
   @IsNotExist('user', { message: '用户名已存在' })
   username: string

   @IsNotEmpty({ message: '密码不能为空' })
   password: string

   @IsNotEmpty({ message: '确认密码不能为空' })
   @IsEnterPassword({ message: '两次密码不一致' })
   enterPassword: string

   @IsNotEmpty({ message: '验证码不能为空' })
   capthaValue: number

   @Allow()
   capthaKey: string
}
